# 案例：打开‘注册实例.html’页面，完成以下操作
# 1). 填写主页面的注册信息
# 2). 填写注册页面A中的注册信息
# 3). 填写注册页面B中的注册信息


from time import sleep
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By

# 1.打开浏览器
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.wait import WebDriverWait

driver = webdriver.Chrome()
# 放大浏览器页面
driver.maximize_window()
# 2.输入访问地址（URL）
url = r"D:\Project\PycharmProjects\Interpreter\注册实例.html";
driver.get(url)


# 1). 填写主页面的注册信息
# 用户名
driver.find_element(By.CSS_SELECTOR,"#user").send_keys("admin")
# 密码
driver.find_element(By.CSS_SELECTOR,"#password").send_keys("123456")
# 电话号码
driver.find_element(By.CSS_SELECTOR,"#tel").send_keys("13012345678")
# 电子邮件
driver.find_element(By.CSS_SELECTOR,"#email").send_keys("123@qq.com")


# 点击'注册A页面'链接
driver.find_element(By.PARTIAL_LINK_TEXT,"A网页").click()
sleep(1)  # 等待新标签页打开
windows = driver.window_handles
# 切换到最新的标签页
driver.switch_to.window(windows[-1])
# 用户名
driver.find_element(By.CSS_SELECTOR,"#userA").send_keys("1111")
# # 密码
driver.find_element(By.CSS_SELECTOR,"#passwordA").send_keys("123456")
# 电话号码
driver.find_element(By.CSS_SELECTOR,"#telA").send_keys("13012345678")
# 电子邮件
driver.find_element(By.CSS_SELECTOR,"#emailA").send_keys("123@qq.com")




